package com.cctc.juc.demo.Athread.Astate;

public class DThreadStateDemo {
    public static void main(String[] args) {
        // 线程状态：NEW -> RUNNABLE -> WAITING -> RUNNABLE -> TERMANITED，不限时等待。
        new Thread(new AWaitingThread(), "WaitingThread").start();
        // 线程状态：NEW -> RUNNABLE -> TIMED_WAITING -> RUNNABLE -> TERMANITED，限时等待。
        new Thread(new BTimedWaitingThread(), "TimedWaitingThread").start();

        /**
         * 线程状态：NEW -> RUNNABLE -> TERMANITED 或者 NEW -> RUNNABLE -> BLOCKED -> RUNNBALE -> TERMANITED
         * 说明：抢锁失败线程进入阻塞状态，等待抢锁成功线程释放锁后被唤醒。
         */
        new Thread(new CBlockedThread(), "BlockedThread-01").start();
        new Thread(new CBlockedThread(), "BlockedThread-02").start();
    }
}
